package com.woniuxy.service.impl;

import com.woniuxy.dao.CustomerDao;
import com.woniuxy.pojo.Customer;
import com.woniuxy.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class CustomerServiceImpl implements CustomerService {
    @Autowired
    private CustomerDao customerDao;
    @Override
    public List<Customer> findAll(String name) {
        return customerDao.findAll(name);
    }

    @Override
    public Boolean save(Customer customer) {
        Boolean flag = false;
        try {
            customerDao.save(customer);
            flag = true;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return flag;
    }

    @Override
    public Boolean del(Integer id) {
        Boolean flag = false;
        try {
            customerDao.del(id);
            flag = true;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return flag;
    }

    @Override
    public Customer findOne(Integer id) {
        return customerDao.findOne(id);
    }

    @Override
    public Boolean update(Customer customer) {
        Boolean flag = false;
        try {
            customerDao.update(customer);
            flag = true;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return flag;
    }
}
